#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main() 
{ 
	//TODO
	vector<string> strings;
	string str;
	while (cin>>str){
		strings.push_back(str);
	}
	map<string, int> maps;
    for (int i=0; i<strings.size(); i++){
		maps[strings[i]]++;
	}
	for (auto it=maps.begin(); it!=maps.end(); it++){
		cout<<it->first<<" "<<it->second<<endl;
	}
	return 0; 
}
